<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">

    <title>阿冬网盘 - 登录 </title>
  
	<!-- Vendors Style-->
	<link rel="stylesheet" href="static/css/vendors_css.css">
	  
	<!-- Style-->  
	<link rel="stylesheet" href="static/css/style.css">
	<link rel="stylesheet" href="static/css/skin_color.css">
	<script src="js/jquery-1.12.4.min.js" ></script>

</head>
	
<body class="hold-transition theme-primary bg-img" style="background-image: url(./img/bg2.jpg)">
	
	<div class="container h-p100">
		<div class="row align-items-center justify-content-md-center h-p100">	
			
			<div class="col-12">
				<div class="row justify-content-center no-gutters">
					<div class="col-lg-5 col-md-5 col-12">
						<div class="bg-white rounded30 shadow-lg">
							<div class="content-top-agile p-20 pb-0">
								<h2 class="text-primary">欢迎使用阿冬网盘</h2>
								<p class="mb-0">请输入账号密码登录继续使用阿冬网盘</p>							
							</div>
							<div class="p-40">
								<form >
									<div class="form-group">
										<div class="input-group mb-3">
											<div class="input-group-prepend">
												<span class="input-group-text bg-transparent"><i class="ti-user"></i></span>
											</div>
											<input type="text" class="form-control pl-15 bg-transparent" id="username" placeholder="请输入您的账号">
										</div>
									</div>
									<div class="form-group">
										<div class="input-group mb-3">
											<div class="input-group-prepend">
												<span class="input-group-text  bg-transparent"><i class="ti-lock"></i></span>
											</div>
											<input type="password" class="form-control pl-15 bg-transparent" id="password" placeholder="请输入您的密码">
											<span id="msg"></span>
										</div>
									</div>

									  <div class="row">
										<div class="col-6">
										  <div class="checkbox">
											<input type="checkbox" id="basic_checkbox_1">
											<label for="basic_checkbox_1">记住账号</label>
										  </div>
										</div>
										<!-- /.col -->
										<div class="col-6">
										 <div class="fog-pwd text-right">
											<a href="javascript:void(0)" class="hover-warning"><i class="ion ion-locked"></i> 忘记密码?</a><br>
										  </div>
										</div>
										<!-- /.col -->
										<div class="col-12 text-center">
										  <button type="button" class="btn btn-danger mt-10" onclick="login()">登录</button>
										</div>
										<!-- /.col -->
									  </div>
								</form>	
								<div class="text-center">
									<p class="mt-15 mb-0">还没有账号? <a href="register.html" class="text-warning ml-5">注册</a></p>
								</div>	
							</div>						
						</div>
					
					</div>
				</div>
			</div>
		</div>
	</div>


	<!-- Vendor JS -->
	<script src="static/js/vendors.min.js"></script>
	<script src="static/js/chat-popup.js"></script>
    <script src="static/js/feather.min.js"></script>

<script>
	function login(){
		//获取用户输入的用户和密码，通过Ajax发送给服务器
		let username = $("#username").val().trim();

		let password = $("#password").val().trim();

	
	
		$.ajax("/login",{
			type:"POST",
			data:{
				username:username,
				password:password
			},
			success:function (data,textStatus){
				
				var dataList = data.split("\r\n");
				let user = JSON.parse(data);
				console.log(user)
				if(user.statusCode == 2000){
						
					// alert(dataList[1]);
					// 把用户名存到session 里
					let list = JSON.stringify(user.data);
					sessionStorage.setItem("username",list);

					console.log(user)
					//将文件列表存到session里
					// sessionStorage.setItem("list",dataList[2]);
					alert(user.errMsg);
					location.href="/index.html";

				}else{
					alert(user.errMsg)
				}
			}
		})

	}

</script>

</body>
</html>
